package gov.army.workshop.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import org.compass.annotations.Searchable;
import org.compass.annotations.SearchableId;
import org.compass.annotations.SearchableProperty;
@Entity
@Table(name="EQMS_JOB_DETAIL")
@Searchable
public class JobDetail extends BaseObject{
	/**
	 * 
	 */
	private static final long serialVersionUID = -8567711222602270821L;
	private Long id;
	private Date dtOfJobCommenced;
	private Date dtOfJobCompleted;
	private int totalManHrs;
	private Double totalJobCost;
	
	@Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @SearchableId
    public Long getId() {
        return id;
    }
    
	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}
	
	/**
	 * @return the dtOfJobCommenced
	 */
	@Column(name = "JOB_DT_START", nullable = false)
    @SearchableProperty
	public Date getDtOfJobCommenced() {
		return dtOfJobCommenced;
	}
	/**
	 * @return the dtOfJobCompleted
	 */
	@Column(name = "JOB_DT_COMPLETED")
    @SearchableProperty
	public Date getDtOfJobCompleted() {
		return dtOfJobCompleted;
	}
	/**
	 * @return the totalManHrs
	 */
	@Column(name = "JOB_TOTAL_MAN_HOUR")
    @SearchableProperty
	public int getTotalManHrs() {
		return totalManHrs;
	}
	/**
	 * @return the totalJobCost
	 */
	@Column(name = "JOB_TOTAL_COST", nullable = false)
    @SearchableProperty
	public Double getTotalJobCost() {
		return totalJobCost;
	}
	
	/**
	 * @param dtOfJobCommenced the dtOfJobCommenced to set
	 */
	public void setDtOfJobCommenced(Date dtOfJobCommenced) {
		this.dtOfJobCommenced = dtOfJobCommenced;
	}
	/**
	 * @param dtOfJobCompleted the dtOfJobCompleted to set
	 */
	public void setDtOfJobCompleted(Date dtOfJobCompleted) {
		this.dtOfJobCompleted = dtOfJobCompleted;
	}
	/**
	 * @param totalManHrs the totalManHrs to set
	 */
	public void setTotalManHrs(int costOfTotalManHrs) {
		this.totalManHrs = costOfTotalManHrs;
	}
	/**
	 * @param totalJobCost the totalJobCost to set
	 */
	public void setTotalJobCost(Double totalJobCost) {
		this.totalJobCost = totalJobCost;
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime
				* result
				+ ((dtOfJobCommenced == null) ? 0 : dtOfJobCommenced.hashCode());
		result = prime
				* result
				+ ((dtOfJobCompleted == null) ? 0 : dtOfJobCompleted.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result
				+ ((totalJobCost == null) ? 0 : totalJobCost.hashCode());
		result = prime * result + totalManHrs;
		return result;
	}
	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		JobDetail other = (JobDetail) obj;
		if (dtOfJobCommenced == null) {
			if (other.dtOfJobCommenced != null)
				return false;
		} else if (!dtOfJobCommenced.equals(other.dtOfJobCommenced))
			return false;
		if (dtOfJobCompleted == null) {
			if (other.dtOfJobCompleted != null)
				return false;
		} else if (!dtOfJobCompleted.equals(other.dtOfJobCompleted))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (totalJobCost == null) {
			if (other.totalJobCost != null)
				return false;
		} else if (!totalJobCost.equals(other.totalJobCost))
			return false;
		if (totalManHrs != other.totalManHrs)
			return false;
		return true;
	}
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "JobDetail [id=" + id + ", dtOfJobCommenced=" + dtOfJobCommenced
				+ ", dtOfJobCompleted=" + dtOfJobCompleted + ", totalManHrs="
				+ totalManHrs + ", totalJobCost=" + totalJobCost + "]";
	}
	
}
